import request from '@/utils/request'
import store from '@/store'

// 获取经纪列表
export function getAgentsList(params) {
  return request({
    url: '/agents',
    method: 'get',
    params
  })
}
// 搜索经纪列表
export function searchAgents(params) {
  return request({
    url: '/agents',
    method: 'get',
    params
  })
}
// 增加经纪列表
export function addAgentsList(data) {
  return request({
    url: '/agents',
    method: 'post',
    data,
    headers: {
      Authorization: `Bearer ${store.getters.token}`
    }
  })
}
// 删除经纪
export function delAgents(id) {
  return request({
    url: '/agents/' + id,
    method: 'delete',
    headers: {
      Authorization: `Bearer ${store.getters.token}`
    }
  })
}
// 获取指定经纪
export function getAgentsById(id) {
  return request({
    url: '/agents/' + id,
    method: 'get'
  })
}
// 更新经纪列表
export function editAgents(data) {
  return request({
    url: '/agents/' + data.id,
    method: 'put',
    data,
    headers: {
      Authorization: `Bearer ${store.getters.token}`
    }
  })
}

// 获取经纪列表总数
export function countAgents() {
  return request({
    url: '/agents/count',
    method: 'get'
  })
}

